<?php
/**
* 获取购物车信息 2013-4-26 by sutroon
* 例如：$('#lblCarCount').load('./WADS/Api/shoppingcar.php?q=getcount&sess=<?php echo session_id(); ?>&r=' + Math.random());
*/
include_once('../Lib/CE/config.php');
// 购物车格式:array('pid1'=>'num1','pid2'=>'num2');
switch($wu->request_string('q')){
	case 'getcount':
		$arr=$wu->session_getcar_as_array('shoppingcar');
		echo is_array($arr)?array_sum($arr):0;
		break;
	case 'getamount':
		$arr=$wu->session_getcar_as_array('shoppingcar');
		if(!is_array($arr)) exit('0');
		exit($biz->get_shoppingcar_amount($arr));
		break;	
	case 'update':
		$wu->session_updatecar('shoppingcar',$wu->request_int('pid'),$wu->request_int('num'),$wu->request_bool('mode'));
		echo 'success';
		break; 
	case 'remove':
		$wu->session_updatecar('shoppingcar',$wu->request_int('pid'),0);
		echo 'success';
		break; 
}
?>